package com.example.ui_view;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class ForRessultActivity extends AppCompatActivity {
    Button btn_get;
    TextView tv_forResult;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_for_ressult);
        btn_get=findViewById(R.id.btn_get);
        tv_forResult=findViewById(R.id.tv_forResult);
        btn_get.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ForRessultActivity.this,Result2Activity.class);
                Bundle bundle = new Bundle();
                String strValue = "Android";
                int intValue = 1001;
                bundle.putString("str_key",strValue);
                bundle.putInt("int_key",intValue);
                intent.putExtras(bundle);
                startActivityForResult(intent,0x1001);
            }
        });
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode==0x1001&&resultCode==0x1011&&data!=null){
            tv_forResult.setText(data.getStringExtra("id"));
        }
    }
}
